import pygame

from actor import ActionByMulti


class WelcomeSprite(pygame.sprite.Sprite):
    def __init__(self, x: int, y: int):
        """
        初始化多张图片组成的精灵
        :param x: 精灵坐标x
        :param y: 精灵坐标y
        """
        super(WelcomeSprite, self).__init__()
        self.action = ActionByMulti("./resources/images/welcome/%d-1.png", 9, True)
        self.pos_x = x
        self.pos_y = y

    def draw(self, surface):
        """
        精灵绘制
        :param surface: 绘制surface
        :return:
        """
        current_img = self.action.get_image()
        surface.blit(current_img, (self.pos_x, self.pos_y))

    def run(self):
        """
        精灵运动,主动运动
        :return:
        """
        if self.pos_x < 1000:
            self.pos_x += 4
